package cate.game.power;

import cate.common.table.d.GDGuild;
import cate.common.table.d.GDHero;
import cate.game.attr.FightAttr;
import cate.game.attr.PowerAttrPart;
import cate.game.role.Role;
import cate.game.role.res.guild.po.GuildPO;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GuildPowerFactor extends PowerAttrPart {


    /**
     * 公会Normal职业属性
     */
    private Map<Byte, FightAttr> jobNormalAttr = new HashMap<>();
    /**
     * 公会PVP职业属性
     */
    private Map<Byte, FightAttr> jobPVPAttr = new HashMap<>();
    /**
     * 公会PVP职业属性
     */
    private Map<Byte, List<Integer>> jobSkills = new HashMap<>();

    private FightAttr activeLevelAttr = new FightAttr();

    public GuildPowerFactor(Role role) {
        if (role == null) {
            return;
        }
        GuildPO guild = role.getRes().guild.getGuild();
        if (guild == null) {
            return;
        }
        for (byte job : GDHero.Job.ALL) {
            FightAttr attrNormal = role.getRes().guild.skill.getAttr(GDGuild.Skill.NORMAL_SKILL_TYPE, job);
            jobNormalAttr.put(job, attrNormal);
            FightAttr attrPVP = role.getRes().guild.skill.getAttr(GDGuild.Skill.PVP_SKILL_TYPE, job);
            jobPVPAttr.put(job, attrPVP);
            List<Integer> list = role.getRes().guild.skill.getSkill(GDGuild.Skill.PVP_SKILL_TYPE, job);
            jobSkills.put(job, list);
        }
        activeLevelAttr = role.getRes().guild.active.onGetAttr();
    }

    public PowerAttrPart buildHeroPart(byte job) {
        PowerAttrPart part = new PowerAttrPart();
        part.addAttr(jobNormalAttr.get(job));
        part.addPvpAttr(jobPVPAttr.get(job));
        part.addPvpSkills(jobSkills.get(job));
        part.addAttr(activeLevelAttr);
        return part;
    }


}
